/**
  其他境外交流项目管理-新增国家公派-回国报道（或短期访学-回国报销）
*/
<template>
    <div class="go-home-report-container">
        <div style="height: 30px;">
            <el-breadcrumb style="float: left;" separator="/">
                <el-breadcrumb-item :to="{ path: '/exchangeProjectApp' }">
                    <span @click="reback()">{{ $t('projectManage.otherOverseasExchange') }}</span>
                </el-breadcrumb-item>
                <el-breadcrumb-item>
                    <span
                        v-if="projectSubCategory === 6"
                    >{{ $t('projectApplication.nationGovernGoHomeReportEdit') }}</span>
                    <span
                        v-if="projectSubCategory === 7"
                    >{{ $t('projectApplication.shortTermVisitRuturnGovernEdit') }}</span>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-card shadow="never" v-loading="loading" body-style="padding: 24px;">
            <div slot="header" class="title">
                <span>{{ $t('projectManage.otherOverseasExchange') }}</span>
                -
                <span
                    v-if="projectSubCategory === 6"
                >{{ $t('projectApplication.nationGovernGoHomeReportEdit') }}</span>
                <span
                    v-if="projectSubCategory === 7"
                >{{ $t('projectApplication.shortTermVisitRuturnGovernEdit') }}</span>
                <el-button
                    style="float:right; margin-top: -5px;"
                    @click="cancel()"
                >{{ $t('common.btn.back') }}</el-button>
            </div>
            <div class="info-container">
                <el-form :model="applyInfo" ref="applyInfo">
                    <!-- 出访时间开始 -->
                    <div class="privacy-title title">{{ $t('projectApplication.visitTime') }}</div>
                    <el-row :gutter="24">
                        <el-col :span="6">
                            <!-- 计划出发时间 -->
                            <el-form-item
                                :label="$t('projectApplication.plannedDepartureTime') + '：'"
                                prop="projectStartTime"
                            >
                                <el-input disabled v-model="projectStartTime"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <!-- 计划回国时间 -->
                            <el-form-item
                                :label="$t('projectApplication.plannedReturnHomeTime') + '：'"
                                prop="projectEndTime"
                            >
                                <el-input disabled v-model="projectEndTime"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <!-- 实际出发时间 -->
                            <el-form-item
                                :label="$t('projectApplication.actualDepartureTime') + '：'"
                                prop="realStartTimeStr"
                                :rules="[{ required: true, message: $t('projectApplication.requireActualDepartureTime'), trigger: 'blur' }]"
                            >
                                <el-date-picker
                                    style="width: 100%"
                                    v-model="applyInfo.realStartTimeStr"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    :placeholder="$t('graduateBase.chooseDateAndTime')"
                                    :picker-options="sjcfsjPickerOptions"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <!-- 实际回国时间 -->
                            <el-form-item
                                :label="$t('projectApplication.actualReturnHomeTime') + '：'"
                                prop="realEndTimeStr"
                                :rules="[{ required: true, message: $t('projectApplication.requireActualReturnHomeTime'), trigger: 'blur' }]"
                            >
                                <el-date-picker
                                    style="width: 100%"
                                    v-model="applyInfo.realEndTimeStr"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    :placeholder="$t('graduateBase.chooseDateAndTime')"
                                    :picker-options="sjhgsjPickerOptions"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="24">
                            <!-- 在校内所作公开访学学术报告 -->
                            <el-form-item
                                :label="$t('projectApplication.academicReport') + '：'"
                                prop="academicReport"
                                :rules="[{ required: true, message: $t('projectApplication.requireAcademicReport'), trigger: 'blur' }]"
                            >
                                <el-input
                                    type="textarea"
                                    :rows="7"
                                    :placeholder="$t('projectApplication.academicReportTip')"
                                    v-model="applyInfo.academicReport"
                                    :maxlength="500"
                                    clearable
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 出访时间结束 -->
                    <!-- 学术成果开始 -->
                    <div class="privacy-title title other-title">
                        <span>{{ $t('projectApplication.academicAchievements') }}</span>
                        <el-button
                            style="float: right;"
                            type="primary"
                            @click="addGoHomeReport()"
                        >{{ $t('common.btn.add') }}</el-button>
                    </div>
                    <el-form :model="academicAchieveTable" ref="academicAchieveTable">
                        <edu-table
                            :pagination="false"
                            :order="false"
                            :selection="false"
                            :tooltipEffect="tooltipEffect"
                            stripe
                            :data="academicAchieveTable.dataList"
                            size="mini"
                        >
                            <!-- 学术成果类型 -->
                            <edu-table-column :label="$t('学术成果类型')" prop="thesisType" width="120">
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.thesisType'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-select
                                            v-model="scope.row.thesisType"
                                            clearable
                                            style="width: 100%"
                                        >
                                            <el-option label="著作" :value="1"></el-option>
                                            <el-option label="期刊论文" :value="2"></el-option>
                                            <el-option label="会议论文" :value="3"></el-option>
                                            <el-option label="专利" :value="4"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 著作论文题目/专利名称 -->
                            <edu-table-column
                                :label="$t('著作论文题目/专利名称')"
                                prop="thesisTitle"
                                width="170"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.thesisTitle'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.thesisTitle"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 发表时间/获批时间（年/月） -->
                            <edu-table-column
                                :label="$t('发表时间/获批时间（年/月）')"
                                prop="publishDate"
                                width="200"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.publishDate'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-date-picker
                                            style="width: 100%"
                                            v-model.trim="scope.row.publishDate"
                                            type="month"
                                            value-format="yyyy-MM"
                                            format="yyyy-MM"
                                            :placeholder="$t('graduateBase.chooseDateAndTime')"
                                        ></el-date-picker>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 本人排名 -->
                            <edu-table-column :label="$t('本人排名')" prop="authorRanking" width="130">
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.authorRanking'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.authorRanking"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            clearable
                                            rows='10'
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!--  刊物名称（著作论文填写）-->
                            <edu-table-column
                                :label="$t('刊物名称（著作论文填写）')"
                                prop="periodicalName"
                                :render-header="renderHeader"
                                width="140"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.periodicalName'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.periodicalName"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 卷/期/页（著作论文填写） -->
                            <edu-table-column
                                :label="$t('卷/期/页（著作论文填写）')"
                                prop="periodicalVolume"
                                :render-header="renderHeader2"
                                width="140"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.periodicalVolume'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.periodicalVolume"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            placeholder="101(4):632-636"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 收录情况(如SCI/EI收录等) -->
                            <edu-table-column
                                :label="$t('收录情况(如SCI/EI收录等)')"
                                prop="collectionSituation"
                                :render-header="renderHeader3"
                                width="140"
                            >
                                <template slot-scope="scope">
                                    <!-- 收录情况 -->
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.collectionSituation'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.collectionSituation"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 专利号及批准号 -->
                            <edu-table-column
                                :label="$t('专利号及批准号')"
                                prop="patentNumber"
                                width="120"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.patentNumber'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.patentNumber"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 主要合作者 -->
                            <edu-table-column
                                :label="$t('主要合作者')"
                                prop="cooperationAuthor"
                                width="120"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.cooperationAuthor'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.cooperationAuthor"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>

                            <!-- 是否有获奖等其他成果/荣誉 -->
                            <edu-table-column
                                :label="$t('是否有获奖等其他成果/荣誉')"
                                prop="otherAchievement"
                                width="200"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        style="margin-top: 15px;"
                                        :prop="'dataList.' + scope.$index + '.otherAchievement'"
                                        label-width="0"
                                        :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                                    >
                                        <el-input
                                            v-model.trim="scope.row.otherAchievement"
                                            :maxlength="32"
                                            type="textarea"
                                            autosize
                                            rows='10'
                                            clearable
                                            :placeholder="$t('common.pla.pleaseInput')"
                                        ></el-input>
                                    </el-form-item>
                                </template>
                            </edu-table-column>
                            <edu-table-column
                                :label="$t('common.text.operation')"
                                fit
                                prop="operate"
                            >
                                <template slot-scope="props">
                                    <el-button
                                        type="text"
                                        @click="deleteReport(props.row)"
                                    >{{ $t('common.btn.delete') }}</el-button>
                                </template>
                            </edu-table-column>
                        </edu-table>
                    </el-form>
                    <!-- 学术成果结束 -->
                    <!-- 上传材料开始 -->
                    <div class="privacy-title title other-title">
                        <span>{{ $t('projectApplication.uploadMaterial') }}</span>
                        <!-- 总结报告模板 下载 -->
                        <el-button
                            style="margin-left: 30px;"
                            type="text"
                            size="medium"
                            @click="downloadSummaryReport()"
                        >{{ $t('projectApplication.summaryReport') }}</el-button>
                        <!-- 考核表模板 下载 -->
                        <el-button
                            type="text"
                            size="medium"
                            @click="downloadAssessTable()"
                        >{{ $t('projectApplication.assessFormTemplate') }}</el-button>
                        <!-- 结题报告模板 下载 -->
                        <el-button
                            type="text"
                            size="medium"
                            @click="downloadConcludingReport()"
                        >{{ $t('projectApplication.concludingReportTemplate') }}</el-button>
                    </div>
                    <el-divider></el-divider>
                    <div
                        style="margin-left: 20px;color: #8896a7;font-size: 12px;"
                    >{{ $t('externamExchangeBase.fileName') }}</div>
                    <el-divider></el-divider>
                    <el-row :gutter="24" class="file-container">
                        <el-col :span="24">
                            <!-- 短期出国访学总结报告 -->
                            <el-form-item
                                :label="$t('projectApplication.summaryReportFile')"
                                prop="file221"
                                ref="file221"
                                label-width="80px"
                                style="margin: 12px 0;"
                                :rules="[{ required: true, message: $t('projectApplication.requireSummaryReportFile'), trigger: 'change'}]"
                            >
                                <el-upload
                                    v-model="applyInfo.file221"
                                    class="upload-demo"
                                    action="/api/commonservice/obsfile/uploadfile"
                                    :data="uploadConfig.data"
                                    :on-exceed="handleExceed"
                                    :before-upload="(file) => beforeUpload(file, 221, 'file221')"
                                    :on-success="(response, file, fileList) => handlerUploadSuccess(response, file, fileList, 221, 'file221')"
                                    :before-remove="(file, fileList) => handlerBeforeRemove(file, fileList, 221, 'file221')"
                                    :on-remove="(file, fileList) => handlerRemove(file, fileList, 221, 'file221')"
                                    :on-error="(err, file, fileList) => handlerUploadError(err, file, fileList, 221, 'file221')"
                                    :on-preview="(file) => downloadMaterial(file, 221, 'file221')"
                                    :limit="1"
                                    :file-list="getFileList(applyInfo.files, 221)"
                                >
                                    <el-button
                                        size="small"
                                        type="primary"
                                    >{{ $t('graduateBase.chooseFile') }}</el-button>
                                </el-upload>
                                <span
                                    class="file-tip-info"
                                >{{ $t('projectApplication.summaryReportFileTip') }}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-divider></el-divider>
                    <el-row :gutter="24" class="file-container">
                        <el-col :span="24">
                            <!-- 短期访学考核表 -->
                            <el-form-item
                                :label="$t('projectApplication.assessFormFile')"
                                prop="file222"
                                ref="file222"
                                label-width="80px"
                                style="margin: 12px 0;"
                                :rules="[{ required: true, message: $t('projectApplication.requireAssessFormFile'), trigger: 'change'}]"
                            >
                                <el-upload
                                    v-model="applyInfo.file222"
                                    class="upload-demo"
                                    action="/api/commonservice/obsfile/uploadfile"
                                    :data="uploadConfig.data"
                                    :on-exceed="handleExceed"
                                    :before-upload="(file) => beforeUpload(file, 222, 'file222')"
                                    :on-success="(response, file, fileList) => handlerUploadSuccess(response, file, fileList, 222, 'file222')"
                                    :before-remove="(file, fileList) => handlerBeforeRemove(file, fileList, 222, 'file222')"
                                    :on-remove="(file, fileList) => handlerRemove(file, fileList, 222, 'file222')"
                                    :on-error="(err, file, fileList) => handlerUploadError(err, file, fileList, 222, 'file222')"
                                    :on-preview="(file) => downloadMaterial(file, 222, 'file222')"
                                    :limit="1"
                                    :file-list="getFileList(applyInfo.files, 222)"
                                >
                                    <el-button
                                        size="small"
                                        type="primary"
                                    >{{ $t('graduateBase.chooseFile') }}</el-button>
                                </el-upload>
                                <span
                                    class="file-tip-info"
                                >{{ $t('projectApplication.assessFormFileTip') }}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-divider></el-divider>
                    <el-row :gutter="24" class="file-container">
                        <el-col :span="24">
                            <!-- 结题报告 -->
                            <el-form-item
                                :label="$t('projectApplication.concludingReportFile')"
                                prop="file223"
                                ref="file223"
                                label-width="80px"
                                style="margin: 12px 0;"
                                :rules="[{ required: true, message: $t('projectApplication.requireConcludingReportFile'), trigger: 'change'}]"
                            >
                                <el-upload
                                    v-model="applyInfo.file223"
                                    class="upload-demo"
                                    action="/api/commonservice/obsfile/uploadfile"
                                    :data="uploadConfig.data"
                                    :on-exceed="handleExceed"
                                    :before-upload="(file) => beforeUpload(file, 223, 'file223')"
                                    :on-success="(response, file, fileList) => handlerUploadSuccess(response, file, fileList, 223, 'file223')"
                                    :before-remove="(file, fileList) => handlerBeforeRemove(file, fileList, 223, 'file223')"
                                    :on-remove="(file, fileList) => handlerRemove(file, fileList, 223, 'file223')"
                                    :on-error="(err, file, fileList) => handlerUploadError(err, file, fileList, 223, 'file223')"
                                    :on-preview="(file) => downloadMaterial(file, 223, 'file223')"
                                    :limit="1"
                                    :file-list="getFileList(applyInfo.files, 223)"
                                >
                                    <el-button
                                        size="small"
                                        type="primary"
                                    >{{ $t('graduateBase.chooseFile') }}</el-button>
                                </el-upload>
                                <span
                                    class="file-tip-info"
                                >{{ $t('projectApplication.concludingReportFileTip') }}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-divider></el-divider>
                    <el-row :gutter="24" class="file-container">
                        <el-col :span="24">
                            <!-- 其他附件 -->
                            <el-form-item
                                :label="$t('projectApplication.otherFileInfo')"
                                prop="file224"
                                ref="file223"
                                label-width="80px"
                                style="margin: 12px 0;"
                                :rules="[{ required: true, message: $t('projectApplication.requireOtherFileInfo'), trigger: 'change'}]"
                            >
                                <el-upload
                                    v-model="applyInfo.file224"
                                    class="upload-demo"
                                    action="/api/commonservice/obsfile/uploadfile"
                                    :data="uploadConfig.data"
                                    :on-exceed="handleExceed"
                                    :before-upload="(file) => beforeUpload(file, 224, 'file224')"
                                    :on-success="(response, file, fileList) => handlerUploadSuccess(response, file, fileList, 224, 'file224')"
                                    :before-remove="(file, fileList) => handlerBeforeRemove(file, fileList, 224, 'file224')"
                                    :on-remove="(file, fileList) => handlerRemove(file, fileList, 224, 'file224')"
                                    :on-error="(err, file, fileList) => handlerUploadError(err, file, fileList, 224, 'file224')"
                                    :on-preview="(file) => downloadMaterial(file, 224, 'file224')"
                                    :limit="1"
                                    :file-list="getFileList(applyInfo.files, 224)"
                                >
                                    <el-button
                                        size="small"
                                        type="primary"
                                    >{{ $t('graduateBase.chooseFile') }}</el-button>
                                </el-upload>
                                <span
                                    class="file-tip-info"
                                >{{ $t('projectApplication.otherFileInfoTip') }}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 上传材料结束 -->
                </el-form>
                <el-divider></el-divider>
                <div style="text-align: right;margin-top: 20px;">
                    <el-button @click="cancel()">{{ $t('common.btn.cancel') }}</el-button>
                    <el-button @click="save()">{{ $t('common.btn.save') }}</el-button>
                    <!-- 只有短期访学才有提交按钮，需要审核，国家公派不需要审核 -->
                    <el-button type="primary" @click="submit()">{{ $t('common.btn.submit') }}</el-button>
                </div>
            </div>
        </el-card>
    </div>
</template>
<script>
import { downloadfile } from 'common/src/api/upload'
import externalExchangeApi from 'common/src/api/externalExchange/externalExchange'
export default {
    components: {},
    data() {
        return {
            compareNameList: [],
            applyInfo: {
                realStartTimeStr: '',
                realEndTimeStr: '',
                academicReport: '',
                file221: '',
                file222: '',
                file223: '',
                file224: '',
                files: [
                    {
                        number: 221,
                        fileId: '',
                        fileName: ''
                    },
                    {
                        number: 222,
                        fileId: '',
                        fileName: ''
                    },
                    {
                        number: 223,
                        fileId: '',
                        fileName: ''
                    },
                    {
                        number: 224,
                        fileId: '',
                        fileName: ''
                    }
                ]
            },
            academicAchieveTable: {
                dataList: []
            },
            uploadConfig: {
                data: { bucketname: 'face', folderpath: 'file' }
            },
            fileFlag: true
        }
    },
    props: {
        applyId: {
            type: String,
            default: ''
        },
        backId: {
            type: String,
            default: ''
        },
        projectSubCategory: {
            type: Number,
            default: 0
        },
        projectStartTime: {
            type: String,
            default: ''
        },
        projectEndTime: {
            type: String,
            default: ''
        }
    },
    computed: {
        // 实际出发时间
        sjcfsjPickerOptions() {
            let _this = this
            return {
                disabledDate: value => {
                    if (_this.applyInfo.realEndTimeStr) {
                        // 计划留学开始时间必须小于计划留学截止时间
                        if (value.getTime() > new Date(_this.applyInfo.realEndTimeStr).getTime()) {
                            return true
                        }
                    }
                    return false
                }
            }
        },
        // 计划留学结束时间
        sjhgsjPickerOptions() {
            let _this = this
            return {
                disabledDate: value => {
                    if (_this.applyInfo.realStartTimeStr) {
                        // 计划留学结束时间必须大于计划留学开始时间
                        if (
                            value.getTime() + 24 * 60 * 60 * 1000 <
                            new Date(_this.applyInfo.realStartTimeStr).getTime()
                        ) {
                            return true
                        }
                    }
                    return false
                }
            }
        }
    },
    created() {},
    async mounted() {
        const response = await externalExchangeApi.selectReturnHomeDetail({
            backId: this.backId
        })
        if (response.code === 200 && response.data) {
            let responseData = JSON.parse(JSON.stringify(response.data))
            this.applyInfo.realStartTimeStr = responseData.realStartTime
            this.applyInfo.realEndTimeStr = responseData.realEndTime
            this.applyInfo.academicReport = responseData.academicReport
            if (responseData.files.length > 0) {
                responseData.files.map(value => {
                    this.applyInfo.files.map(element => {
                        if (value.number === element.number) {
                            element.fileId = value.fileId
                            element.fileName = value.fileName
                        }
                    })
                })
            }
            this.academicAchieveTable.dataList = responseData.achievement
        }
    },
    methods: {
        // 校验特殊字符$
        checkSpecial(rule, value, callback) {
            let regEn = /[`$]/im
            if (regEn.test(value)) {
                callback(new Error(this.$t('graduateBase.specialText')))
            } else {
                callback()
            }
        },
        reback() {
            this.$emit('change-project-index')
        },
        renderHeader(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '刊物名称</br>著作论文填写'
                }
            })
        },
        renderHeader2(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '卷/期/页</br>著作论文填写'
                }
            })
        },
        renderHeader3(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '收录情况</br>如SCI/EI收录等'
                }
            })
        },
        // 新增行
        addGoHomeReport() {
            this.academicAchieveTable.dataList.push({
                uniqueId: new Date().getTime(),
                thesisType: '',
                thesisTitle: '',
                publishDate: '',
                authorRanking: '',
                periodicalName: '',
                periodicalVolume: '',
                patentNumber: '',
                collectionSituation: '',
                cooperationAuthor: '',
                otherAchievement: ''
            })
        },
        // 删除行
        deleteReport(row) {
            let _this = this
            for (let i = _this.academicAchieveTable.dataList.length - 1; i >= 0; i--) {
                if (_this.academicAchieveTable.dataList[i]) {
                    if (
                        (_this.academicAchieveTable.dataList[i].uniqueId &&
                            _this.academicAchieveTable.dataList[i].uniqueId === row.uniqueId) ||
                        (_this.academicAchieveTable.dataList[i].backAchievementId &&
                            _this.academicAchieveTable.dataList[i].backAchievementId ===
                                row.backAchievementId)
                    ) {
                        _this.academicAchieveTable.dataList.splice(i, 1)
                    }
                }
            }
        },
        // 下载总结报告模板
        downloadSummaryReport() {
            externalExchangeApi.templateDownload({
                type: 221,
                fileName: '总结报告模板.docx'
            })
        },
        // 下载考核表模板
        downloadAssessTable() {
            externalExchangeApi.templateDownload({
                type: 222,
                fileName: '考核表模板.docx'
            })
        },
        // 下载结题报告模板
        downloadConcludingReport() {
            externalExchangeApi.templateDownload({
                type: 223,
                fileName: '结题报告模板.docx'
            })
        },
        // 文件类方法开始
        handleExceed(files, fileList) {
            this.$message.error(this.$t('externamExchangeBase.limitOneFile'))
        },
        // 获取文件fileList
        getFileList(fileArr, number) {
            let fileArray = []
            fileArr.map(value => {
                if (value.number === number) {
                    if (value.fileId) {
                        fileArray.push({
                            url: value.fileId,
                            name: value.fileName,
                            uid: value.fileId
                        })
                    }
                    let instanceName = 'file' + number
                    this.applyInfo[instanceName] = value.fileId
                }
            })
            return fileArray
        },
        handlerBeforeRemove(file, fileList, fileNumber, key) {},
        handlerRemove(file, fileList, fileNumber, key) {
            this.applyInfo.files.map((value, index) => {
                if (fileNumber === value.number) {
                    value.fileId = ''
                    value.fileName = ''
                    this.$set(this.applyInfo, key, '')
                }
            })
            this.compareNameList.forEach((val, index) => {
                if (key === val.number) {
                    this.compareNameList.splice(index, 1)
                }
            })
        },
        beforeUpload(file, fileNumber, key) {
            const fileSizeFlag = file.size && file.size / 1024 / 1024 < 5
            let fileNameLength = file.name.length <= 64
            let fileName = file.name.substring(0, file.name.lastIndexOf('.'))
            let fileNameRepeat = false
            let fileType = file.name.substring(file.name.lastIndexOf('.') + 1)
            let uploadFlag = false
            // this.applyInfo.files.map((value, index) => {
            //     if (fileNumber === value.number) {
            //         value.fileId = file.uid
            //         value.fileName = file.name
            //          this.$set(this.applyInfo, key, value.fileId)
            //     }
            // })
            let compFileName = true
            if (this.compareNameList && this.compareNameList.length > 0) {
                this.compareNameList.forEach(val => {
                    if (val.fileName === file.name) {
                        compFileName = false
                    }
                })
            }
            if (fileNumber === 221) {
                uploadFlag = fileType === 'doc' || fileType === 'docx'
            } else if (fileNumber === 224) {
                uploadFlag = fileType === 'rar' || fileType === 'zip'
            } else {
                uploadFlag = fileType === 'pdf'
            }
            if (!uploadFlag) {
                window.vueApp.showMsgBox({
                    message: this.$t('minor.approve.uploadFileError'),
                    callback: () => {}
                })
            }
            if (!compFileName) {
                window.vueApp.showMsgBox({
                    message: this.$t('externamExchangeBase.sameName'),
                    callback: () => {}
                })
            }
            if (!fileSizeFlag) {
                window.vueApp.showMsgBox({
                    message: this.$t('externamExchangeBase.uploadSizeError'),
                    callback: () => {}
                })
            }
            if (!fileNameLength) {
                window.vueApp.showMsgBox({
                    message: this.$t('externamExchangeBase.uploadNameLength'),
                    callback: () => {}
                })
            }
            if (this.applyInfo.files.length > 0) {
                this.applyInfo.files.map(value => {
                    if (value.fileName.length > 0) {
                        let fileNameStr = value.fileName.substring(
                            0,
                            value.fileName.lastIndexOf('.')
                        )
                        let fileTypeStr = value.fileName.substring(
                            value.fileName.lastIndexOf('.') + 1
                        )
                        if (
                            fileType === fileTypeStr &&
                            fileNameStr === fileName &&
                            value.number !== fileNumber
                        ) {
                            fileNameRepeat = true
                        }
                    }
                })
            }
            if (fileNameRepeat) {
                window.vueApp.showMsgBox({
                    message: this.$t('externamExchangeBase.uploadNameRepeat'),
                    callback: () => {}
                })
            }
            this.fileFlag =
                uploadFlag && fileSizeFlag && fileNameLength && !fileNameRepeat && compFileName
            if (
                !(uploadFlag && fileSizeFlag && fileNameLength && !fileNameRepeat && compFileName)
            ) {
                return false
            } else {
                this.compareNameList.push({
                    fileName: file.name,
                    number: key
                })
            }
        },
        handlerUploadSuccess(response, file, fileList, fileNumber, key) {
            let _this = this
            let responseCode = response.code
            if (responseCode === 200) {
                _this.applyInfo.files.map((value, index) => {
                    if (fileNumber === value.number) {
                        value.fileId = Object.values(response.data)[0].objectkey
                        value.fileName = Object.values(response.data)[0].fileName
                        this.$refs['applyInfo'].clearValidate(key)
                        _this.$set(_this.applyInfo, key, value.fileId)
                    }
                })
            }
        },
        handlerUploadError(response, file, fileList, fileNumber, key) {
            this.$message({
                message: this.$t('graduateBase.uploadFail'),
                type: 'error'
            })
            this.applyInfo.files.map((value, index) => {
                if (fileNumber === value.number) {
                    value.fileId = ''
                    value.fileName = ''
                    this.$set(this.applyInfo, key, '')
                }
            })
            this.compareNameList.forEach((val, index) => {
                if (key === val.number) {
                    this.compareNameList.splice(index, 1)
                }
            })
        },
        downloadMaterial(file, fileNumber, key) {
            if (file.url) {
                downloadfile(file.url)
            } else if (file.status === 'success' && file.response.data) {
                downloadfile(file.response.data[file.name].objectkey)
            }
        },
        // 取消
        cancel() {
            this.$confirm(
                this.$t('externamExchangeBase.cancelTip'),
                this.$t('externamExchangeBase.prompt'),
                {
                    confirmButtonText: this.$t('externamExchangeBase.confirm'),
                    cancelButtonText: this.$t('externamExchangeBase.cancel'),
                    type: 'warning'
                }
            ).then(() => {
                this.$emit('change-project-index')
            })
        },
        save(type) {
            this.$refs['applyInfo'].validate(valid => {
                this.$refs['academicAchieveTable'].validate(tableValid => {
                    if (valid && tableValid) {
                        let fileInfo = JSON.parse(JSON.stringify(this.applyInfo.files))
                        let params = {
                            backId: this.backId,
                            realStartTimeStr: this.applyInfo.realStartTimeStr,
                            realEndTimeStr: this.applyInfo.realEndTimeStr,
                            academicReport: this.applyInfo.academicReport,
                            achievement: this.academicAchieveTable.dataList,
                            files: fileInfo
                        }
                        externalExchangeApi.modifyApplyReturnHome(params).then(res => {
                            if (res.code === 200) {
                                if (type === '1') {
                                    externalExchangeApi
                                        .submitReturnHomeReimburse({
                                            backId: res.data.backId
                                        })
                                        .then(response => {
                                            if (response.code === 200) {
                                                this.$message({
                                                    type: 'success',
                                                    message: this.$t(
                                                        'externamExchangeBase.submitSuccessfully'
                                                    )
                                                })
                                                this.$emit('change-project-index')
                                            }
                                        })
                                } else {
                                    this.$message({
                                        type: 'success',
                                        message: this.$t('externamExchangeBase.savedSuccessfully')
                                    })
                                    this.$emit('change-project-index')
                                }
                            }
                        })
                    }
                })
            })
        },
        submit() {
            this.save('1')
        }
    }
}
</script>
<style lang="scss" scoped>
.project-application-container {
    .el-breadcrumb__item:last-child ::v-deep {
        .el-breadcrumb__inner {
            color: #606266;
            font-weight: bold;
            cursor: default;
        }
    }
    .el-breadcrumb__item ::v-deep {
        .is-link {
            color: #aaa;
            font-weight: unset;
        }
        .is-link:hover {
            color: #409eff;
        }
    }
    .title {
        font-weight: bold;
        font-size: 18px;
    }
    .privacy-title {
        margin-bottom: 20px;
    }
    .other-title {
        margin-top: 20px;
    }
    .audit-container {
        padding-left: 15px;
    }
    .operate-footer {
        text-align: right;
    }
    .info-container {
        padding-left: 15px;
    }
    .file-container ::v-deep {
        margin-left: 10px !important;
        .el-form-item__label {
            text-align: left !important;
        }
        .upload-demo {
            width: 450px;
            text-align: center;
        }
        .file-tip-info {
            flex: 1;
            color: #8896a7;
        }
        .el-form-item__content {
            display: flex;
        }
    }
    .el-divider--horizontal {
        margin: 7px 0 !important;
    }
}
</style>
